﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GtsServer.Service.Model;
using GtsServer.DAL;
using System.Data;

namespace GtsServer.Service.Controller
{
    public class FeedBackController
    {
        public FeedBackResponse AddFeedback(FeedBackRequest request)
        {
            FeedBackResponse response = new FeedBackResponse()
            {
                feedback = false
            };

            string userAccount = BaseController.Account(request.info);

            if (string.IsNullOrEmpty(userAccount))
                return response;

            FeedBackDAL dal = new FeedBackDAL();
            DataSet ds = dal.Add(userAccount, request.feedback.contact, request.feedback.text);

            int id = 0;
            if (ds != null && ds.Tables[0].Rows.Count > 0)
                id = Convert.ToInt32(ds.Tables[0].Rows[0][0]);

            response.feedback = id > 0 ? true : false;

            return response;
        }
    }
}
